import java.io.Serializable;
import java.util.Hashtable;

public class ServerProfile implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String name;
	private int id;
	private String ip;
	private int port;
	private Hashtable<String, Integer> delay = new Hashtable<>();

	public ServerProfile(String name, String ip, String port, String[] d, int numOfServers) {
		super();
		this.name = name;
		this.id = Integer.parseInt(name);
		this.ip = ip;
		this.port = Integer.parseInt(port);
		for (int i = 1; i < numOfServers; i++) {
			int aID = (this.id + i)%numOfServers;
			int aDelay = Integer.parseInt(d[i-1]);
			delay.put(aID +"", aDelay);
		}
		
		delay.put(name, 0);
//		System.out.println("Server " + id + ": ");
//		System.out.println(delay.keySet() + " " + delay.values());
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}
	
	public String toString() {
		return this.name + ":" + this.ip + ":" + this.port;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getDelay(ServerProfile s) {
		return delay.get(s.getName());
	}
}
